<?php

use App\Models\AdminMenuModel;
use Illuminate\Database\Migrations\Migration;

return new class extends Migration {
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up(): void
    {
        migrationUp(__FILE__);
        $array = [
            '首页' => [
                'icon' => 'fa-home',
                'uri' => '/',
            ],
            '客服' => [
                'icon' => 'fa-bars',
                'child' => [
                    ['订单', 'shopOrder/paging'],
                    ['售后', 'shopOrderReturn/paging'],
                    //['商品管理', 'shopProduct/paging'],
                    //['上传商品', 'importProduct'],
                    //['随手买', 'buyWill'],
                ],
            ],
            '管理员' => [
                'icon' => 'fa-bars',
                'child' => [
                    ['用户', 'auth/users'],
                    ['角色', 'auth/roles'],
                    ['权限', 'auth/permissions'],
                    ['菜单', 'auth/menu'],
                    ['日志', 'auth/logs'],
                ],
            ],
            '审核' => [
                'icon' => 'fa-bars',
                'child' => [
                    ['分销资质', 'audit/inviteCertification'],
                    ['拍卖资质', 'audit/auctionCertification'],
                    ['银行卡', 'audit/bank'],
                    ['实名认证', 'audit/realNameAuth'],
                    ['意见反馈', 'audit/feedback'],
                    ['拍卖', 'audit/auction'],
                    ['售后', 'audit/afterSale'],
                    ['提现', 'audit/withdraw'],
                ],
            ],
            '优惠券' => [
                'icon' => 'fa-bars',
                'child' => [
                    ['列表', 'coupon'],
                ],
            ],
            '商品' => [
                'icon' => 'fa-bars',
                'child' => [
                    ['列表', 'shopProduct'],
//                    ['捡漏2.0', 'plug'],
                    ['助力', 'shopProductHelp'],
                    ['规格', 'shopProductSpec'],
                    ['订单', 'shopOrder'],
                    ['售后', 'shopOrderReturn'],
                ],
            ],
            '拍卖' => [
                'icon' => 'fa-bars',
                'child' => [
                    ['列表', 'auction'],
                    ['订单', 'auctionOrder'],
                ],
            ],
            '财务' => [
                'icon' => 'fa-bars',
                'child' => [
                    ['余额', 'amount'],
                    ['充值记录', 'userAdjustment'],
                    ['提现', 'withdraw'],
                ],
            ],
            '用户' => [
                'icon' => 'fa-bars',
                'child' => [
                    ['列表', 'shopUser'],
                    ['地址', 'address'],
                ],
            ],
            '员工' => [
                'icon' => 'fa-bars',
                'child' => [
                    ['列表', 'staff'],
                    ['客服', 'kefu'],
                ],
            ],
            '设置' => [
                'icon' => 'fa-bars',
                'child' => [
                    ['首页模块', 'indexModule'],
                    ['轮播图', 'slide'],
                    ['配置', 'systemConfig'],
                    ['活动专区', 'activityZone'],
                    ['退货地址', 'returnAddress'],
                ],
            ],
            '营销' => [
                'icon' => 'fa-bars',
                'child' => [
                    ['销售记录', 'salesRecord'],
                    ['素材', 'sourceMaterial/paging'],
                ],
            ],
            '其它' => [
                'icon' => 'fa-bars',
                'child' => [
                    ['上传文件', 'uploadFile'],
                    ['分类管理', 'category'],
                    ['支付回调', 'notify'],
                    ['退款回调', 'refund'],
                    ['支付', 'payment'],
                    ['支付号', 'paymentRelated'],
                    ['操作日志', 'operateLog'],
                    ['行政区划', 'area']
                ],
            ],
        ];
        $arr = [];
        $index = 1;
        $i = 0;
        foreach ($array as $k => $v) {
            $arr[] = [
                'order' => $i++,
                'parentId' => 0,
                'title' => $k,
                'icon' => $v['icon'],
                'uri' => $v['uri'] ?? null,
            ];
        }
        foreach ($array as $v) {
            $i = 0;
            foreach ($v['child'] ?? [] as $v1) {
                $arr[] = [
                    'order' => $i++,
                    'parentId' => $index,
                    'title' => $v1[0],
                    'uri' => $v1[1],
                    'icon' => null,
                ];
            }
            $index++;
        }
        AdminMenuModel::insert($arr);
    }
};
